class Solution {
public:
    int countSubstrings(string s) {
        int n = s.size();
        vector<vector<bool>>f(n, vector<bool>(n, 1));
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i + 1; j < n; j++) {
                f[i][j] = (s[i] == s[j]) && f[i + 1][j - 1];
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (f[i][j]) {
                    ans++;
                    cout << "i==" << i << endl;
                    // cout<<"j=="<<j<<endl;
                }
            }
        }
        return ans;
    }
};